home *** CD-ROM | disk | FTP | other *** search
- /*
- File: CVideoOutput.h
-
- Description: SimpleVideoOut is an example of using QuickTimes FireWire video
- output component to play a DV stream (.dv movie) out to a DV Camera.
- This code is based on VidOutApp originally written by Jay Lloyd, Casey King
- and Adrienne Wang.
-
- Author: era
-
- Copyright: © Copyright 2000 Apple Computer, Inc. All rights reserved.
-
- Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
- ("Apple") in consideration of your agreement to the following terms, and your
- use, installation, modification or redistribution of this Apple software
- constitutes acceptance of these terms. If you do not agree with these terms,
- please do not use, install, modify or redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject
- to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
- copyrights in this original Apple software (the "Apple Software"), to use,
- reproduce, modify and redistribute the Apple Software, with or without
- modifications, in source and/or binary forms; provided that if you redistribute
- the Apple Software in its entirety and without modifications, you must retain
- this notice and the following text and disclaimers in all such redistributions of
- the Apple Software. Neither the name, trademarks, service marks or logos of
- Apple Computer, Inc. may be used to endorse or promote products derived from the
- Apple Software without specific prior written permission from Apple. Except as
- expressly stated in this notice, no other rights or licenses, express or implied,
- are granted by Apple herein, including but not limited to any patent rights that
- may be infringed by your derivative works or by other works in which the Apple
- Software may be incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
- WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
- WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
- COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
- OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
- (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Change History (most recent first): <1> 1/28/00 initial release
-
- */
-
- /*
- The CVideoOutput Class is very easy to use and encapsulates the basic set of functions required
- to output a DV Stream over FireWire.
-
- To instantiate a CVideoOutput object pass it your Movie.
-
- Open( const unsigned char inClientNameStr[], const short inMode )
- Opens the FireWire video output component, registers a client name with the component
- and sets up the display mode. This method also acquires the audio media handlers for up to five
- audio tracks for use later when setting up the sound device and will automatically close
- a video output component if it's already open before re-instantiating a new one.
-
- Begin( Boolean inUseVOsdev = true, Boolean inUseVOClk = true )
- Gains exclusive access to the hardware, sets up the sound output and the clock component
- associated with the video output component. Begin also acquires the GWorld used by the video
- output component. Both the sound and clock parameters are set to 'true' by default.
-
- SetEchoPort( const CGrafPtr inEchoPort = NULL )
- Allows you to display video both on an external video display and in a window.
- Pass in a CGrafPtr to specify a window to display video sent to the device. When video
- is displayed in the window you specify, the video is displayed in the window and sent
- to the normal output of the video output device. SimpleVideoOut by default turns the
- EchoPort on but allows you to turn it off.
-
- SetSoundDevice( const Boolean inUseVOsdev = true )
- This call will turn on/off the use of the video output components sound device, by
- default SimpleVideoOut turns it on. Passing in 'true' will set up the use of the
- video output components sound device and also sets up the clock component which is used
- to synchronize video and sound for a movie to the rate of the display. Passing in 'false'
- will use the default sound device and default clock.
-
- End( void )
- Relinquishes exclusive access to the hardware. Also called by Close().
-
- Close( void )
- Closes the component instance and zeros the object. It is also called by the objects destructor.
-
- GetGWorld( void )
- Returns a pointer to the graphics world used by a video output component.
-
- GetError( void )
- Returns the last return code generated by the system.
- */
-
- #ifndef __CVIDEOOUTPUT_H__
- #define __CVIDEOOUTPUT_H__
-
- #include <QuickTimeComponents.h>
- #include <MediaHandlers.h>
-
- namespace dts {
-
- const UInt8 kMaxAudioTrax = 5;
-
- enum {
- eAudioRate48khz = (long)0xBB800000, /* 48000.00000 in fixed-point */
- eAudioRate44khz = (long)0xAC440000, /* 44100.00000 in fixed-point */
- eAudioRate32khz = (long)0x7D000000 /* 32000.00000 in fixed-point */
- };
-
- class CVideoOutput {
- public:
- CVideoOutput( const Movie inMovie );
- ~CVideoOutput() { Close(); };
-
- OSErr Open( const unsigned char inClientNameStr[], const short inMode );
- void Close( void );
-
- OSErr Begin( Boolean inUseVOsdev = true, Boolean inUseVOClk = true );
- void End( void );
-
- OSErr SetEchoPort( const CGrafPtr inEchoPort = NULL );
- OSErr SetSoundDevice( const Boolean inUseVOsdev = true );
-
- GWorldPtr GetGWorld( void ) const { if ( mVideoOutputInUse == true ) return mVOutputGWorld; else return NULL; };
- OSErr GetError( void ) const { return rc; };
-
- private:
- Movie mMovie;
- GWorldPtr mVOutputGWorld;
- Component mVOutputComponent;
- QTVideoOutputComponent mVOutputInstance;
- Component mDefaultSoundOutComponent;
- Component mSoundOutComponent;
- ComponentInstance mMovieClockInstance;
- MediaHandler mAudioMediaHandler[kMaxAudioTrax];
- UInt8 mNumberAudioTracks;
- Boolean mVideoOutputInUse;
- ComponentResult rc;
- };
-
- } // namespace
-
- #endif // __CVIDEOOUTPUT_H__